<?php
$xtpl = new XTemplate("modules/home/banner_task.htm");
//--
$UPLOAD = new UPLOAD();
//--
$POST = $_POST;

if($_POST[type] == 'NEW'){	
    $arrName = array();
    $arrDes = array();
    if($_FILES['image']['name'] !=''){
        $POST['image'] = $UPLOAD->doUploadImage("upload/banner/", 'image', '', '200', 'off');
    }
	$DB->DBInsert('banner', $POST);
	//--
	$GUI->redir("?mod=home&act=banner");
}
elseif($_POST[type] == 'EDIT'){
	if($_FILES['image']['name'] !=''){
	 	$POST['image'] = $UPLOAD->doUploadImage("upload/banner/", 'image', '', '200', 'off');
	}
	$DB->DBUpdate('banner', $POST, "WHERE id = '".$POST['id']."'");

        
	$GUI->redir("?mod=home&act=banner");
}
//--
//--

$name = array();
$description = array();
if($_GET['id'] != ''){
    $row = $DB->FetchData('banner','*',"WHERE id='".$_GET['id']."'");
    $row[type] = 'EDIT';
    $title = unserialize($row['title']);
    $description = unserialize($row['description']);
    if($row['image']!=''){	
        $row['show_image']='<img src="../upload/banner/thumb'.$row['image'].'" border="0" width="150">';
    }
    if($row['status']=='1'){
        $row['status']='checked="checked"';
    }else{
        $row['status']='';
    }
}else{
    $row['type'] = 'NEW';
    $row['status']="checked";
}
$first = true;
//--
$xtpl->assign("write",$row);
//--
//--
$waypathlink = '&raquo;&nbsp;<a href="?mod=home&act=banner" class="waypath">Banner Management</a>:&nbsp;'.$row[type];
$xtpl_main->assign("waypathlink",$waypathlink);
//--
//--
$save_button = $GUI->button_ren("Save","javascript: doSavenews();");
$xtpl->assign("save_button",$save_button);
//--
$cancel_button = $GUI->button_ren("Cancel","javascript: add('?mod=home&act=banner');");
$xtpl->assign("cancel_button",$cancel_button);

//$xtpl->parse("center");
//$xtpl->assign("center_file",$xtpl->text("center"));

//--
//--
?>